//
//  IManager+ModuleToplist.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-9-26.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModuleToplist.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "FrameworkRelativeDefines.h"
#import "RCTopListTypeDataModel.h"
#import "RCMerchantsListDataModel.h"
#import "GloableEngineService.h"
#import "NSString+NSString_Ex_.h"

@implementation IManager(ModuleToplist)

-(int64_t)requestTopListTypeInfo:(id<IManagerDelegate>)delegate{
    
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCToplistTypePrefix,[GloableEngineService sharedInstance].selectedCityID];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);

    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCTopListTypeDataModel class]
                                                     withDataDelegate:delegate];
}

-(int64_t)requestTopListDetailInfo:(NSString *)typeID withPn:(NSInteger)pn withRn:(NSInteger)rn withLat:(NSString *)lat withLon:(NSString *)lon withDelegate:(id<IManagerDelegate>)delegate{
    if ([NSString stringIsNullOrEmpty:typeID]) {
        return kInvalidRequestId;
    }
  
    NSString *urlSuffix = [NSString stringWithFormat:kRCToplistDetailPrefix,[GloableEngineService sharedInstance].selectedCityID,typeID,pn,rn,lat,lon];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    KFLog(@"request url %@",url);
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCMerchantsListDataModel class]
                                                     withDataDelegate:delegate];
}

-(int64_t)requestTopListMoreTypeInfo:(NSString *)typeID withDelegate:(id<IManagerDelegate>)delegate{
    if ([NSString stringIsNullOrEmpty:typeID]) {
        return kInvalidRequestId;
    }
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCToplistMoreTypePrefix,typeID,[GloableEngineService sharedInstance].selectedCityID];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    KFLog(@"request url %@",url);
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCTopListTypeMoreDataModel class]
                                                     withDataDelegate:delegate];
}

@end
